package main

// 349
func intersection(nums1 []int, nums2 []int) []int {

	m1 := make(map[int]struct{})
	m2 := make(map[int]struct{})

	for _, v := range nums1 {
		m1[v] = struct{}{}
	}

	for _, v := range nums2 {
		m2[v] = struct{}{}
	}

	if len(m1) > len(m2) {
		m1, m2 = m2, m1
	}
	inters := []int{}
	for k := range m1 {
		if _, ok := m2[k]; ok {
			inters = append(inters, k)
		}
	}
	return inters

}

func main() {

}
